Navigation

  • index
  • next |
  • previous |
  • PyHowTo documentation »
  • Basic »
  • String »

Table of Contents

Python v3.7 HowTos:

  • ----------------
  • Recursion
  • Backtracking
  • Dynamic Programming
  • Greedy
  • Sort
  • Binary Search
  • Depth First Search [DFS]
  • Breadth First Search [BFS]
  • Binary Search Tree [BST]
  • ----------------
  • Array
  • String
  • Heap
  • Stack
  • Queue
  • Tree
  • Linked List
  • Hash Table
  • Bit Manipulation
  • Two Pointers
  • Math
  • Decorator
  • ----------------
  • Basic
  • Intermediate
  • Advanced
  • Interview
  • ----------------
  • Spark
  • Tkinter
  • Turtle
  • Games
  • Web
  • ----------------
  • About
  • History

Previous topic

Count repeated characters - collections

Next topic

Print the index of the character

Quick search

Print a special symbols¶

Print the square and cube symbol in the area of a rectangle and volume of a cylinder.
Sample output:
The area of the rectangle is: 1256.66cm2
The volume of the cylinder is: 1254.725cm3
area = 1256.66
volume = 1254.725

decimals = 2
print("The area of the rectangle is: \
       {0:.{1}f}cm\u00b2".format(area, decimals))

decimals = 3
print("The volume of the cylinder is: \
       {0:.{1}f}cm\u00b3".format(volume, decimals))

Output:

The area of the rectangle is: 1256.66cm²
The volume of the cylinder is: 1254.725cm³

See also

https://www.w3resource.com/python-exercises/string/python-data-type-string-exercise-43.php

Navigation

  • index
  • next |
  • previous |
  • PyHowTo documentation »
  • Basic »
  • String »
© Copyright 2020, Sergiy Zaytsev, szaytsev@hotmail.com. Created using Sphinx 2.3.0.